﻿<Window x:Class="MLifterSettingsManager.ExtensionForm"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:MLifterSettingsManager="clr-namespace:MLifterSettingsManager"
    xmlns:local="clr-namespace:MLifterSettingsManager" x:Name="extensionForm"
    Title="Extension Manager" Height="500" Width="600" WindowStartupLocation="CenterOwner" ShowInTaskbar="False">
    <Window.Resources>
        <MLifterSettingsManager:ByteToStringConverter x:Key="byteToStringConverter" />
        <MLifterSettingsManager:VersionToStringConverter x:Key="versionToStringConverter" />
    </Window.Resources>
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <DockPanel Grid.Column="0" Grid.Row="0" VerticalAlignment="Top" Background="LightGreen">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" Grid.Row="0" Margin="0,5,5,5" FontWeight="Bold" Content="File:" />
                <TextBlock Grid.Column="1" Grid.Row="0" x:Name="TextBoxExtension" Text="{Binding ExtensionFile.ExtensionPath}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center"></TextBlock>
                <Button  Grid.Column="2" Grid.Row="0" x:Name="ButtonLoadExtension" Click="ButtonLoadExtension_Click" Margin="5">Load...</Button>
                <Button  Grid.Column="3" Grid.Row="0" x:Name="ButtonNewExtension" Click="ButtonNewExtension_Click" Margin="5">New...</Button>

            </Grid>
        </DockPanel>
        <DockPanel Grid.Column="0" Grid.Row="1" VerticalAlignment="Top" x:Name="DockPanelExtensionSettings"  IsEnabled="{Binding ExtensionFileLoaded}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="75"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" FontWeight="Bold" Content="Extension Settings: " />

                <Label Grid.Column="0" Grid.Row="2" Content="Guid" FontWeight="Normal" />
                <TextBlock Grid.Column="1" Grid.Row="2" x:Name="TextBlockGuid" Text="{Binding ExtensionFile.Extension.Id}" VerticalAlignment="Center" />

                <Label Grid.Column="0" Grid.Row="3" Content="Name" FontWeight="Normal" />
                <TextBox Grid.Column="1" Grid.Row="3" x:Name="TextBoxName" Text="{Binding ExtensionFile.Extension.Name}" />

                <Label Grid.Column="0" Grid.Row="4" Content="Version" FontWeight="Normal" />
                <TextBox Grid.Column="1" Grid.Row="4" x:Name="TextBoxVersion" Text="{Binding Path=ExtensionFile.Extension.Version, Converter={StaticResource versionToStringConverter}}"></TextBox>

                <Label Grid.Column="0" Grid.Row="5" Content="Type" FontWeight="Normal" />
                <ComboBox Grid.Column="1" Grid.Row="5" x:Name="ComboBoxExtensionTyp" SelectedItem="{Binding ExtensionFile.Extension.Type}" SelectionChanged="ComboBoxExtensionTyp_SelectionChanged"></ComboBox>

                <Label Grid.Column="0" Grid.Row="6" Content="Start File" FontWeight="Normal" />
                <ComboBox Grid.Column="1" Grid.Row="6" x:Name="ComboBoxStartFile" IsEnabled="{Binding StartFilesAvailable}" ItemsSource="{Binding ExtensionDataFiles}" SelectedItem="{Binding ExtensionFile.Extension.StartFile}" SelectionChanged="ComboBoxStartFile_SelectionChanged"></ComboBox>

                <DockPanel Grid.Column="0" Grid.Row="7" Grid.ColumnSpan="2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="75"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Label Grid.Column="0" Grid.Row="1" Content="Data" Margin="0,5,5,5" FontWeight="Normal" />
                        <TextBlock Grid.Column="1" Grid.Row="1" x:Name="TextBlockDataFile" Margin="5" Text="{Binding Path=ExtensionFile.Extension.Data.Length, Converter={StaticResource byteToStringConverter}}" VerticalAlignment="Center"></TextBlock>
                        <Button Grid.Column="2" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" x:Name="ButtonBrowseDataFile" Click="ButtonBrowseDataFile_Click">Load from file...</Button>
                    </Grid>
                </DockPanel>
            </Grid>
        </DockPanel>
        <DockPanel Grid.Column="0" Grid.Row="2" VerticalAlignment="Stretch" x:Name="DockPanelExtensionOperations"  IsEnabled="{Binding ExtensionFileLoaded}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Label Grid.Row="0" Grid.Column="0" FontWeight="Bold" Content="Extension Actions: "></Label>
                <ListBox Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Actions}" x:Name="listBoxActions">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="75" />
                                    <ColumnDefinition Width="75" />
                                    <ColumnDefinition Width="100" />
                                    <ColumnDefinition Width="100" />
                                </Grid.ColumnDefinitions>

                                <TextBlock Grid.Column="0" Margin="5,0,5,0" FontWeight="Bold">Action:</TextBlock>
                                <TextBlock Grid.Column="1" Margin="5,0,5,0" Text="{Binding Kind}"/>
                                
                                <TextBlock Grid.Column="2" Margin="25,0,5,0" FontWeight="Bold">Execution:</TextBlock>
                                <ComboBox Grid.Column="3" Margin="5,0,5,0" ItemsSource="{Binding ElementName=extensionForm, Path=ExtensionActionExecutions}" 
                                      SelectedItem="{Binding Execution}"/>
                                
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </DockPanel>
        <DockPanel Grid.Column="0" Grid.Row="3" VerticalAlignment="Center">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
				
				<Label>
					<Hyperlink Click="HyperlinkHelp_Click">Help</Hyperlink>
				</Label>
				
                <Button Grid.Row="0" Grid.Column="2" x:Name="ButtonCancel" Margin="5" Click="ButtonCancel_Click">Close</Button>
            </Grid>
        </DockPanel>
    </Grid>
</Window>
